package jjn.round1;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Jjn
 * @since 2022/10/15 23:01
 */
public class LeetCode1441_BuildArrayWithStack {
    public List<String> buildArray(int[] target, int n) {
        List<String> result = new ArrayList<>(n);
        int start = 1;
        for (int i : target) {
            for (int j = start; j <= i; j++, start = j) {
                if (j < i) {
                    result.add("Push");
                    result.add("Pop");
                } else {
                    result.add("Push");
                }
            }
        }
        return result;
    }
}
